﻿using System;
using System.Runtime.InteropServices;
using Ast.Core.WinApi;

namespace Ast.Core.Services.ObjectDefinitions
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public struct DriverObject
    {
        public short Type;

        public short Size;

        public IntPtr DeviceObject;

        public uint Flags;

        public IntPtr DriverStart;

        public uint DriverSize;

        public IntPtr DriverSection;

        public IntPtr DriverExtension;

        public Structure.UnicodeString DriverName;

        public IntPtr HardwareDatabase;

        public IntPtr FastIoDispatch;

        public IntPtr DriverInit;

        public IntPtr DriverStartIo;

        public IntPtr DriverUnload;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)]
        public IntPtr[] MajorFunction;
    }

    /*
lkd> dt _DRIVER_OBJECT
nt!_DRIVER_OBJECT
   +0x000 Type             : Int2B
   +0x002 Size             : Int2B
   +0x004 DeviceObject     : Ptr32 _DEVICE_OBJECT
   +0x008 Flags            : Uint4B
   +0x00c DriverStart      : Ptr32 Void
   +0x010 DriverSize       : Uint4B
   +0x014 DriverSection    : Ptr32 Void
   +0x018 DriverExtension  : Ptr32 _DRIVER_EXTENSION
   +0x01c DriverName       : _UNICODE_STRING
   +0x024 HardwareDatabase : Ptr32 _UNICODE_STRING
   +0x028 FastIoDispatch   : Ptr32 _FAST_IO_DISPATCH
   +0x02c DriverInit       : Ptr32     long 
   +0x030 DriverStartIo    : Ptr32     void 
   +0x034 DriverUnload     : Ptr32     void 
   +0x038 MajorFunction    : [28] Ptr32     long 
 
     */
}